package platformer.controller.collisions;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import platformer.controller.collisions.effects.CollisionEffect;


/**
 * The Collision Dictionary.
 */
public abstract class PlatformerCollisionDictionary implements CollisionDictionary
{
	
	/** The dictionary structure. */
	private static Map<PlatformerCollisionDictionaryKey,ArrayList<CollisionEffect>> dictionary = 
				new HashMap<PlatformerCollisionDictionaryKey,ArrayList<CollisionEffect>>();
	
	private void init() {
		
	}
	
	public PlatformerCollisionDictionary(){
		init();
	}

	/**
	 * Gets the effects for the collider and the collided.
	 *
	 * @param collider the collider
	 * @param collided the collided
	 * @return the effects for
	 */
	public Collection<CollisionEffect> getEffectsFor( final Collisionable collider, final Collisionable collided )
	{
		
		List<CollisionEffect> returnList = dictionary.get(
			new PlatformerCollisionDictionaryKey(
				collider.getCollisionCategory(), 
				collided.getCollisionCategory()
			)
		);
		
		if(returnList == null)
			return new ArrayList<CollisionEffect>();
		
		return returnList;
		
	}

}
